using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_admin_Colors_AddColor : System.Web.UI.UserControl
{
    public event EventHandler ColorCreated;
    protected void btnAddColor_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            DateTime myDate = Convert.ToDateTime(txtYearMonth.Text);

            DAL.ArchiveBackground myBG = new DAL.ArchiveBackground();
            myBG.Color = txtColor.Text;
            myBG.YearMonth = myDate.ToString("yyyy/MM");
            DAL.ArchiveBackgrounds.Add(myBG);

            if (ColorCreated != null)
            {
                ColorCreated(this, new EventArgs());
            }
        }
    }
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        DateTime myDate = DateTime.Now;
        args.IsValid = DateTime.TryParse(args.Value, out myDate);
    }
}
